import { Paxios } from '../base';

export function apiControllerStatus(): Promise<iRespBase<any>> {
  return Paxios.getInstance().get('/status');
}
export function apiMeters(): Promise<iRespBase<any>> {
  return Paxios.getInstance().get('/meters');
}

export function apiInstrumentErrors(): Promise<iRespBase<any>> {
  return Paxios.getInstance().get('/error');
}

export function apiAddBatch(data: { template: string; new_batch: string }): Promise<iRespBase<any>> {
  return Paxios.getInstance().get('/create_batch', data);
}
export function apiReports(): Promise<iRespBase<any>> {
  return Paxios.getInstance().get('/reports');
}
export function apiSamples(): Promise<iRespBase<any>> {
  return Paxios.getInstance().get('/samples');
}
/**
 * 仪器开/关火
 * @param value
 * @returns
 */
export function apiPlasma(value: 1 | 0): Promise<iRespBase<any>> {
  return Paxios.getInstance().get('/plasma?value=' + value);
}
/**
 * 仪器开/关真空
 * @param value
 * @returns
 */
export function apiVacuum(value: 1 | 0): Promise<iRespBase<any>> {
  return Paxios.getInstance().get('/vacuum?value=' + value);
}
/**
 * 仪器运行/停止
 * @param value
 * @returns
 */
export function apiRun(value: 1 | 0): Promise<iRespBase<any>> {
  return Paxios.getInstance().get('/run?value=' + value);
}
/**
 * 仪器暂停/恢复
 * @param value
 * @returns
 */
export function apiPause(value: 1 | 0): Promise<iRespBase<any>> {
  return Paxios.getInstance().get('/pause?value=' + value);
}
/**
 * 新增样品
 * @param data
 * @returns
 */
export function apiImportSamples(data: iTemplate): Promise<iRespBase<any>> {
  return Paxios.getInstance().post('/import_samples', [data]);
}
/**
 * 获取批处理模板列表
 * @returns
 */
export function apiGetAllBatchTemplates(): Promise<iRespBase<{ templates: string[]; use_template: string }>> {
  return Paxios.getInstance().get('/batch_templates');
}

/**
 * 获取自动熄火配置
 * @returns
 */
export function apiGetAutoPlasma(): Promise<iRespBase<{ value: boolean; duration_min: number; start: string; end: string }>> {
  return Paxios.getInstance().get('/auto_plasma');
}
export function apiPostAutoPlasma(params: { value: boolean; duration_min: number; start: string; end: string }): Promise<iRespBase<void>> {
  return Paxios.getInstance().get('/config_auto_plasma', params);
}

export function apiGetCurrentBatch(): Promise<iRespBase<{ batch: string }>> {
  return Paxios.getInstance().get('/current_batch');
}
